#pragma once

#include "Sensor.h"
#include <vector>
#include <cstdint>

class GameObject;
class Transform;
class MapData;

struct VisionDef : public SensorDef
{
	mtMETA_DEC;
	float distance;
	float angle;
	uint32_t filterMask;
};

class Vision : public Sensor
{
	mtMETA_DEC;
public:
	bool initWith(VisionDef* def);

	void onStart();

	GameObject*const* getObjects() const;
	size_t getObjectsCount() const;

	void Query();

	GameObject* getNearest(std::function<bool (GameObject*)> filter = nullptr) const;

	Signal<void (GameObject*)> eventObjectNoticed;
	Signal<void (GameObject*)> eventObjectLost;
protected:

	std::vector<GameObject*> _objects;
	MapData* _map;
	Transform* _cachedTansform;
	float _distance;
	float _angle;
	uint32_t _filterMask;
};